package com.example.springboot.service.impl;

import com.example.springboot.entity.Discussion;
import com.example.springboot.entity.DiscussionAndUser;
import com.example.springboot.mapper.DiscussionMapper;
import com.example.springboot.service.IDiscussionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DiscussionService implements IDiscussionService {
    @Autowired
    DiscussionMapper discussionMapper;


    @Override
    public List<DiscussionAndUser> getTree(Integer discussionType, Integer positionId) {
        List<DiscussionAndUser> discussion = DiscussionAndUser.buildDiscussionTree(discussionMapper.getTree(discussionType,positionId));
        return discussion;
    }

    @Override
    public void addDiscussion(Discussion discussion) {
        discussionMapper.addDiscussion(discussion);
    }
}